package com.medical.blood.config;

import me.chanjar.weixin.miniapp.api.WxMaService;
import me.chanjar.weixin.miniapp.api.impl.WxMaServiceImpl;
import me.chanjar.weixin.miniapp.config.impl.WxMaDefaultConfigImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WxMessageConfig {
    @Value("${wx.miniapp.app-id}")
    private String appId;
    @Value("${wx.miniapp.secret}")
    private String secret;

    @Bean
    public WxMaService wxMaService() {
        WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
        config.setAppId(appId);
        config.setSecret(secret);
        WxMaService service = new WxMaServiceImpl();
        service.setWxMaConfigStorage(config);
        return service;
    }
}